package com.acme.domain.bank;

import java.util.ArrayList;

import com.acme.bankapp.service.bank.EmailService;

public class Bank {

	private ArrayList<Client> clients;
	private ClientPegistrationListener[] listeners;
	
	public Bank(ClientPegistrationListener[] listeners){
		this.listeners = listeners;
		this.clients = new ArrayList<Client>();
	}

	public ArrayList<Client> getClients() {
		return clients;
	}
	
	static class PrintClientListener implements ClientPegistrationListener{

		@Override
		public void onClientAdded(Client c) {
			System.out.println(c.getSalutation());
		}
	}
	
	static class EmailNotificationlistener implements ClientPegistrationListener{

		private EmailService emailService;

		public EmailNotificationlistener() {
			emailService = new EmailService();
		}
		
		@Override
		public void onClientAdded(Client c) {
			//System.out.println("Notification email for " + c.getSalutation() + " to be sent");
			StringBuilder emailAdress = new StringBuilder();
			emailAdress.append(c.getName());
			emailAdress.append("@xxx.com") ;
			emailService.sendnotificationEmail(c, emailAdress.toString());
		}
		
		public EmailService getEmailService() {
			return emailService;
		}
		
	}

	public ClientPegistrationListener[] getListeners() {
		return listeners;
	}
	
}
